package com.feng.store.controller.ex;

import com.feng.store.controller.BaseController;
import com.feng.store.entity.Address;
import com.feng.store.service.IAddressService;
import com.feng.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("address")
public class AddressController extends BaseController {
    @Autowired
    private IAddressService addressService;

    /**
     * 新增用户的收获地址
     * @param address
     * @param session
     * @return
     */
    @RequestMapping("add_new_address")
    public JsonResult<Void> addNewAddress(Address address, HttpSession session){
        String username = getUsernameFromSession(session);
        Integer uid = getuidFromSession(session);
        addressService.addNewAddress(address,username,uid);
        return new JsonResult<>(OK);
    }
}
